package com.yzh.homework.homework05;

/**
 * @author 于振晗
 * @title: Instrument
 * @description: TODO 乐器类
 * @date 2020年08月26日
 * @path com.yzh.homework.homework05
 */
//乐器类
public class Instrument {

    //发出声音
    public void makeSound(){
        System.out.println("当前奏乐"+this.getClass());
    }
}

//二胡类
class Erhu extends Instrument{

    //发出声音
    public void makeSound(){
        System.out.println("当前奏乐二胡");
    }
}

//钢琴类
class Piano extends Instrument{

    //发出声音
    public void makeSound(){
        System.out.println("当前奏乐钢琴");
    }
}

//小提琴
class Violin extends Instrument{

    //发出声音
    @Override
    public void makeSound(){
        System.out.println("当前奏乐小提琴");
    }
}

//乐手类
class Musician{

    public static void play(Instrument instrument){
        instrument.makeSound();
    }

    public static void main(String[] args) {
        play(new Violin());
    }
}
